package javaRMI;

import java.net.*;
import java.io.*;

public class JavaRMI {
	public Socket 	sock;
	public InputStreamReader reader;
	public PrintWriter writer;
	
	public JavaRMI(){
		try{
		sock=new Socket("127.0.0.1",4000);
		reader=new InputStreamReader(sock.getInputStream());
		writer=new PrintWriter(sock.getOutputStream());
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public void sendMessage(String message){
		writer.println(message);
		writer.flush();
	}
	
	public String getMessage(){
		String message=null;
		try{
		BufferedReader br=new BufferedReader(reader);
		message=br.readLine();
		}catch(Exception e){
			e.printStackTrace();
		}
		return message;
	}
}
